<template>
    <div>
            <table>
                <tr>
                    <td>商品</td>
                    <td>价格</td>
                    <td>图片</td>
                    
                </tr>
                <tr v-for=" i in order_list" :key="i.id">
                    <td>{{i.goods.goods_name}}</td>
                    <td>{{i.goods.goods_price}}</td>
                    <td><img :src="base_url + i.goods.img" alt=""></td>
                    <td></td>
                </tr>
            </table>
            <h1>合计:{{price_sum}}￥ </h1><h1>积分：{{this.fen}}</h1>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
                base_url:"http://127.0.0.1:8000",
                user_id:sessionStorage.getItem("token"),
                order_list:[],
                fen:sessionStorage.getItem("fen")
        }
    },
     computed:{
        price_sum(){
            let sum =0
            for(let i  in this.order_list){
                sum += parseInt(this.order_list[i]. goods.goods_price)
            }
            return sum
        }
     
    },
    methods: {
            get_order(){
                axios({
                    url : this.base_url +"/app01/order/",
                    method:"get",
                    params:{"user":this.user_id}
                }).then(res=>{
                    this.order_list=res.data.data
                    console.log(this.order_list)
                })
            }
    },
    created() {
        this.get_order()
    }
}
</script>

<style scoped>

</style>
